<html>
<style>
table{
	font-size:11px;
	font-family:Arial, Helvetica, sans-serif;
}
</style>
<body onLoad="window.print();">

<table width="700px" border="0" cellpadding="0" cellspacing="0">
	<tbody>
		<tr>
			<td><img src="<?php echo _compute_public_path('logo_bw', 'images', 'png', true);?>" /> </td>
		</tr>
		<tr>
			<td height="10" colspan="2">&nbsp;</td>
		</tr>
	</tbody>
</table>

<table width="700px" border="0" cellspacing="0" cellpadding="0" class="datagrid">

</tr>
    <td width="21%"><strong>Station:</strong> <?php echo $bill->getBuilding()->getStation();?></td>
    <td width="30%"><strong>Building No. :</strong> <?php echo $bill->getBuilding()->getBuildingNo() ;?></td>
    <td width="26%"><strong>Unit / Formation:</strong> <?php echo $bill->getOccupant()->getUnit();?></td>
    <td width="23%" style="font-size:16px"><strong>Bill History</strong></td>
</tr> 

<tr style="height:20px;">
    <td><strong>Army No. :</strong> <?php echo $bill->getOccupant()->getArmyNo() ;?></td>
    <td><strong>Rank / Name:</strong> <?php echo $bill->getOccupant()->getRank(). ' ' .$bill->getOccupant()->getName();?></td>
    <td><strong>Billing Month: </strong><?php echo $bill->getBillingDate('M-Y');?></td>
    <td rowspan="11" style="vertical-align:text-top">
    	<table border="1" cellpadding="0" cellspacing="0" width="100%">
        	<tr >
            	<td><strong>Month</strong></td>
                <td><strong>Units</strong></td>
                <td><strong>Bill</strong></td>
                <td><strong>Arears</strong></td>
                <?php $index = 0;?>
                <?php foreach ($previous_bills as $m=> $previous_bill):?>
                <?php $index++;?>
					<?php if ($index >= 13): break; else:?>
                    <tr height="15px">
                        <td align="left"><?php echo $previous_bill->getBillingDate('M-y') ;?></td>
                        <td align="left"><?php echo $previous_bill->getUnitsConsumed() - $previous_bill->getUnitsFree();?></td>
                        <td align="left"><?php echo $previous_bill->getGrandTotal();?></td>
                        <td align="left"><?php if($previous_bill->getPaymentStatus() == 0){ echo $previous_bill->getGrandTotal();} else {echo "0";}?></td>
                    </tr>
                    <?php endif;?>
                <?php endforeach;?>
               
        </table>
    </td>
</tr>

<tr style="height:20px;">
    <td><strong>Meter No. :</strong> <?php echo $bill->getBuilding()->getMeterNo();?></td>
    <td><strong>Consumer No. :</strong> <?php echo $bill->getBuilding()->getConsumerNo();?></td>
    <td>&nbsp;</td>
    
</tr>

<tr>
	<td colspan="3">&nbsp;</td>
  </tr>

<tr style="height:20px;">
    <td colspan="3" style="font-size:16px; background-color:#F2F2F2;"><strong>Electricity Bill Details</strong></td>
  </tr>

<tr style="height:20px;">
    <td><strong>Previous Reading:</strong> <?php echo $bill->getPreviousReading();?></td>
    <td><strong>Present Reading:</strong> <?php echo $bill->getPresentReading();?></td>
    <td><strong>Unit Consumed:</strong> <?php echo $bill->getUnitsConsumed();?></td>
  </tr>

<tr style="height:20px;">
    <td><strong>Electricity Billing:</strong> Rs. <?php echo $bill->getUnitsTotal() ;?></td>
    <td><strong>Split AC (Flat Rate):</strong> Rs. <?php echo $bill->getSplitCharges();?></td>
    <td><strong>Window AC (Flat Rate):</strong> Rs. <?php echo $bill->getWindowCharges();?></td>
  </tr>

<tr style="height:20px;">
    <td>&nbsp;</td>
    <?php if ($bill_type == 'soldier'):?>
    <td><strong>Units Billed: </strong><?php echo $billed = $bill->getUnitsConsumed() - $bill->getUnitsFree();?></td>
    <td><strong>Free Auth - JCOs/Sldr:</strong> <?php echo $bill->getUnitsFree();?></td>
    <?php else: ?>
    <td colspan="2">&nbsp;</td>
    <?php endif;?>
  </tr>
  
<tr style="height:20px;">
    <td colspan="3" style="font-size:16px; background-color:#F2F2F2;"><strong>Gas Water/TV &amp; Misc Bill Details</strong></td>
</tr>

<tr style="height:20px;">
    <td><strong>Water Charges: Rs. </strong> <?php echo $bill->getWaterCharges();?></td>
    <td><strong>TV Charges: Rs. </strong> <?php echo $bill->getTvCharges();?></td>
    <td><strong>Gas Charges: Rs. </strong> <?php echo $bill->getGasCharges();?></td>
    <td></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
</tr>


<tr style="height:20px;">
    <td><strong>Misc Charges: Rs. </strong> <?php echo $bill->getMiscCharges();?></td>
    <td><strong>Meter Rent: Rs. </strong><?php echo $bill->getMeterRent() ;?></td>
    <td>&nbsp;</td>
  </tr>



<tr style="height:30px;">
    <td colspan="3">&nbsp;</td>
  </tr>

<tr style="height:30px;">
    <td colspan="3" style="font-size:14px">5% House Rent Rs._____________ to be deducted by concerned UA(RSPA)</td>
    <td style="border:1px solid #000; font-size:15px"><strong>Grand Total:</strong> <span> Rs.<?php echo $bill->getGrandTotal();?></span></td>
  </tr>

</table>

<table width="700px" border="0" cellspacing="0" cellpadding="0">
<tr>
	<td width="73%" valign="top">
        <table width="93%" border="0" cellspacing="0" cellpadding="0" class="form">
            <tr valign="top" style="font-size:16px">
                <td><strong>Improtant Notes:</strong></td>
            </tr>
            <tr valign="top">
                <td>1. Please mention "meter reading" on occupation/vacation returns.</td>
            </tr>
            <tr>
                <td>2. Please return DUPLICATE CCOPY of recovered bill with full details to GE (ARMY) JMR office.</td>
            </tr>
            <tr>
                <td>3. In case of any query, please contact  GE (ARMY) JMR TEL: 36075.</td>
            </tr>
        </table>
    </td>

    <td width="27%">
    
    
    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="form">
			<?php if($bill_type == 'officer'):?>
            <tr>
            	<td colspan="3"><h4>Tarrif Details: Officer</h4></td>
            </tr>

				<?php foreach ($tarrifRates as $tarrif):?>
                <tr>
                    <td align="right"><?php echo $tarrif->getTitle() ?> </td>
                    <td> : Rs. </td>
                    <td> <?php echo $tarrif->getOfficerRate();?></td>
                    </tr>
                <?php endforeach;?>
            
            <?php elseif($bill_type == 'commercial'):?>
			<?php
			 	$c = new Criteria;
				$c->add(CalcValuePeer::TITLE, 'commercial_rate');
				$commercial_rate = CalcValuePeer::DoSelectOne($c);
			?>
            <tr>
            	<td colspan="3"><h4>Tarrif Details: Commercial</h4></td>
            </tr>
            <tr>
            	<td align="right">Commercial Rate</td>
                <td> : Rs. </td>
                <td> <?php echo $commercial_rate->getValue();?></td>
                </tr>
            
            <?php else:?>
            <tr>
            	<td colspan="3"><h4>Tarrif Details: JCO/OR/Civil</h4></td>
            </tr>
				<?php foreach ($tarrifRates as $tarrif):?>
                <tr>
                    <td align="right"><?php echo $tarrif->getTitle() ?> </td>
                    <td> : Rs. </td>
                    <td> <?php echo $tarrif->getCivilRate();?></td>
                    </tr>
                <?php endforeach;?>
                <?php endif; ?>
            
            </table>
    </td>
</tr>

<tr>
	<td colspan="2" height="20px">&nbsp;</td>
</tr>

<tr>
	<td colspan="2" style="border-top:1px dashed #000;">&nbsp;  </td>
</tr>

</table>

<!--Second Copy of Bill-->

<table width="700px" border="0" cellpadding="0" cellspacing="0">
	<tbody>
		<tr>
			<td><img src="<?php echo _compute_public_path('logo_bw', 'images', 'png', true);?>" /> </td>
		</tr>
		<tr>
			<td height="10" colspan="2">&nbsp;</td>
		</tr>
	</tbody>
</table>

<table width="700px" border="0" cellspacing="0" cellpadding="0" class="datagrid">

</tr>
    <td width="21%"><strong>Station:</strong> <?php echo $bill->getBuilding()->getStation();?></td>
    <td width="30%"><strong>Building No. :</strong> <?php echo $bill->getBuilding()->getBuildingNo() ;?></td>
    <td width="26%"><strong>Unit / Formation:</strong> <?php echo $bill->getOccupant()->getUnit();?></td>
    <td width="23%" style="font-size:16px"><strong>Bill History</strong></td>
</tr> 

<tr style="height:20px;">
    <td><strong>Army No. :</strong> <?php echo $bill->getOccupant()->getArmyNo() ;?></td>
    <td><strong>Rank / Name:</strong> <?php echo $bill->getOccupant()->getRank(). ' ' .$bill->getOccupant()->getName();?></td>
    <td><strong>Billing Month: </strong><?php echo $bill->getBillingDate('M-Y');?></td>
    <td rowspan="11" style="vertical-align:text-top">
    	<table border="1" cellpadding="0" cellspacing="0" width="100%">
        	<tr >
            	<td><strong>Month</strong></td>
                <td><strong>Units</strong></td>
                <td><strong>Bill</strong></td>
                <td><strong>Arears</strong></td>
                <?php $index = 0;?>
                <?php foreach ($previous_bills as $m=> $previous_bill):?>
                <?php $index++;?>
					<?php if ($index >= 13): break; else:?>
                    <tr height="15px">
                        <td align="left"><?php echo $previous_bill->getBillingDate('M-y') ;?></td>
                        <td align="left"><?php echo $previous_bill->getUnitsConsumed() - $previous_bill->getUnitsFree();?></td>
                        <td align="left"><?php echo $previous_bill->getGrandTotal();?></td>
                        <td align="left"><?php if($previous_bill->getPaymentStatus() == 0){ echo $previous_bill->getGrandTotal();} else {echo "0";}?></td>
                    </tr>
                    <?php endif;?>
                <?php endforeach;?>
               
        </table>
    </td>
</tr>

<tr style="height:20px;">
    <td><strong>Meter No. :</strong> <?php echo $bill->getBuilding()->getMeterNo();?></td>
    <td><strong>Consumer No. :</strong> <?php echo $bill->getBuilding()->getConsumerNo();?></td>
    <td>&nbsp;</td>
    
</tr>

<tr>
	<td colspan="3">&nbsp;</td>
  </tr>

<tr style="height:20px;">
    <td colspan="3" style="font-size:16px; background-color:#F2F2F2;"><strong>Electricity Bill Details</strong></td>
  </tr>

<tr style="height:20px;">
    <td><strong>Previous Reading:</strong> <?php echo $bill->getPreviousReading();?></td>
    <td><strong>Present Reading:</strong> <?php echo $bill->getPresentReading();?></td>
    <td><strong>Unit Consumed:</strong> <?php echo $bill->getUnitsConsumed();?></td>
  </tr>

<tr style="height:20px;">
    <td><strong>Electricity Billing:</strong> Rs. <?php echo $bill->getUnitsTotal() ;?></td>
    <td><strong>Split AC (Flat Rate):</strong> Rs. <?php echo $bill->getSplitCharges();?></td>
    <td><strong>Window AC (Flat Rate):</strong> Rs. <?php echo $bill->getWindowCharges();?></td>
  </tr>

<tr style="height:20px;">
    <td>&nbsp;</td>
    <?php if ($bill_type == 'soldier'):?>
    <td><strong>Units Billed: </strong><?php echo $billed = $bill->getUnitsConsumed() - $bill->getUnitsFree();?></td>
    <td><strong>Free Auth - JCOs/Sldr:</strong> <?php echo $bill->getUnitsFree();?></td>
    <?php else: ?>
    <td colspan="2">&nbsp;</td>
    <?php endif;?>
  </tr>
  
<tr style="height:20px;">
    <td colspan="3" style="font-size:16px; background-color:#F2F2F2;"><strong>Gas Water/TV &amp; Misc Bill Details</strong></td>
</tr>

<tr style="height:30px;">
    <td><strong>Water Charges: Rs. </strong> <?php echo $bill->getWaterCharges();?></td>
    <td><strong>TV Charges: Rs. </strong> <?php echo $bill->getTvCharges();?></td>
    <td><strong>Gas Charges: Rs. </strong> <?php echo $bill->getGasCharges();?></td>
    <td></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
</tr>


<tr style="height:20px;">
    <td><strong>Misc Charges: Rs. </strong> <?php echo $bill->getMiscCharges();?></td>
    <td><strong>Meter Rent: Rs. </strong><?php echo $bill->getMeterRent() ;?></td>
    <td>&nbsp;</td>
  </tr>



<tr style="height:30px;">
    <td colspan="3">&nbsp;</td>
  </tr>

<tr style="height:30px;">
    <td colspan="3" style="font-size:14px">5% House Rent Rs._____________ to be deducted by concerned UA(RSPA)</td>
    <td style="border:1px solid #000; font-size:15px"><strong>Grand Total:</strong> <span> Rs.<?php echo $bill->getGrandTotal();?></span></td>
  </tr>

</table>

<table width="700px" border="0" cellspacing="0" cellpadding="0">
<tr>
	<td width="73%" valign="top">
        <table width="93%" border="0" cellspacing="0" cellpadding="0" class="form">
            <tr valign="top" style="font-size:16px">
                <td><strong>Improtant Notes:</strong></td>
            </tr>
            <tr valign="top">
                <td>1. Please mention "meter reading" on occupation/vacation returns.</td>
            </tr>
            <tr>
                <td>2. Please return DUPLICATE CCOPY of recovered bill with full details to GE (ARMY) JMR office.</td>
            </tr>
            <tr>
                <td>3. In case of any query, please contact  GE (ARMY) JMR TEL: 36075.</td>
            </tr>
        </table>
    </td>

    <td width="27%">
    
    
    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="form">
			<?php if($bill_type == 'officer'):?>
            <tr>
            	<td colspan="3"><h4>Tarrif Details: Officer</h4></td>
            </tr>

				<?php foreach ($tarrifRates as $tarrif):?>
                <tr>
                    <td align="right"><?php echo $tarrif->getTitle() ?> </td>
                    <td> : Rs. </td>
                    <td> <?php echo $tarrif->getOfficerRate();?></td>
                    </tr>
                <?php endforeach;?>
            
            <?php elseif($bill_type == 'commercial'):?>
			<?php
			 	$c = new Criteria;
				$c->add(CalcValuePeer::TITLE, 'commercial_rate');
				$commercial_rate = CalcValuePeer::DoSelectOne($c);
			?>
            <tr>
            	<td colspan="3"><h4>Tarrif Details: Commercial</h4></td>
            </tr>
            <tr>
            	<td align="right">Commercial Rate</td>
                <td> : Rs. </td>
                <td> <?php echo $commercial_rate->getValue();?></td>
                </tr>
            
            <?php else:?>
            <tr>
            	<td colspan="3"><h4>Tarrif Details: JCO/OR/Civil</h4></td>
            </tr>
				<?php foreach ($tarrifRates as $tarrif):?>
                <tr>
                    <td align="right"><?php echo $tarrif->getTitle() ?> </td>
                    <td> : Rs. </td>
                    <td> <?php echo $tarrif->getCivilRate();?></td>
                    </tr>
                <?php endforeach;?>
                <?php endif; ?>
            
            </table>
    </td>
</tr>


</table>

</body>
</html>